https://int0x33.medium.com/day-65-change-linux-root-password-with-shadow-file-permission-issues-680698069156

Check /etc/shadow file permissions:

ls -la /etc/shadow

You should see…

**-rw-rw-rw-**

This means that the owner, group and all users have read and write permission for the file. Big win for us.

Generate new root password & Su2Root

openssl passwd <-hash_format> -salt <any_word_as_salt> <The_actual_password>

Here we used passwd to specify that we want to generate a Linux hashed password, -1 means MD5 hash and salt is abc then the actual password

openssl passwd -1 salt abc password123

Example password:

This must be replaced between semicolons after the name: $1$WXYViePQ$KBzlD0/sekZbcbzvo1AHI.